﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using MetaHeuristics.Collections;

#endregion

namespace MetaHeuristics.Aco.Collections
{
    public class PheromoneMatrix : SymmetricFloatMatrix
    {
        private float tau0;
        private float min=float.MaxValue;
        private float max=float.MinValue;

        public PheromoneMatrix(int rowCount, float tau0)
            :base(rowCount,tau0)
        {
            this.tau0 = tau0;
        }

        public float Tau0
        {
            get
            {
                return this.tau0;
            }
        }

        public virtual void Update()
        {
            min=float.MaxValue;
            max=float.MinValue;

            for (int i = 0; i < this.Count; ++i)
            {
                min = Math.Min(min, this[i]);
                max = Math.Max(max, this[i]);
            }
        }

        public float Min
        {
            get
            {
                return this.min;
            }
        }

        public float Max
        {
            get
            {
                return this.max;
            }
        }

        public virtual float GetNormalized(int i, int j)
        {
            return checked( (this[i, j] - this.min) / (this.max - this.min) );
        }
    }
}
